﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace l1cs.server.serverpackets
{
    public class S_Message_YN : ServerBasePacket
    {
        private byte[] _byte = null;

        public S_Message_YN( int type, String msg1 )
        {
            buildPacket( type, msg1, null, null, 1 );
        }

        public S_Message_YN( int type, String msg1, String msg2 )
        {
            buildPacket( type, msg1, msg2, null, 2 );
        }

        public S_Message_YN( int type, String msg1, String msg2, String msg3 )
        {
            buildPacket( type, msg1, msg2, msg3, 3 );
        }

        private void buildPacket( int type, String msg1, String msg2, String msg3,
                int check )
        {
            writeC( Opcodes.S_OPCODE_YES_NO );
            writeH( type );
            if ( check == 1 )
            {
                writeS( msg1 );
            }
            else if ( check == 2 )
            {
                writeS( msg1 );
                writeS( msg2 );
            }
            else if ( check == 3 )
            {
                writeS( msg1 );
                writeS( msg2 );
                writeS( msg3 );
            }
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = getBytes();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] S_Message_YN";
        }
    }
}
